package com.example.goodpet.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitSingleton {

    private static Retrofit retrofit1=null;
    private static Retrofit retrofit2=null;

    private RetrofitSingleton(){}

    public static Retrofit getRetrofitConstance(){
        if (retrofit1!=null)return retrofit1;
        else {
            Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
            retrofit1= new Retrofit.Builder().baseUrl(Constants.BASE_URL).addConverterFactory(GsonConverterFactory.create(gson)).build();
            return retrofit1;
        }
    }

    public static Retrofit getRetrofitNetConfig(){
        if (retrofit2!=null)return retrofit2;
        else {
            Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
            retrofit2 = new Retrofit.Builder().baseUrl(AppNetConfig.BASE_URL).addConverterFactory(GsonConverterFactory.create(gson)).build();
            return retrofit2;
        }
    }

}
